<?php
/**
 * Created by b17
 * 2/15/12 5:53 PM
 */

namespace Managers;

class EmailFileParser
{
    private $baseDir;

    public function __construct()
    {
        $this->baseDir = dirname(APPLICATION_PATH) . \Zend_Registry::get('config')->upload->dir;
    }

    public function parse($file)
    {
        $fullPath = $this->baseDir . DIRECTORY_SEPARATOR . $file;
        $mimeType = mime_content_type($fullPath);
        switch ($mimeType) {
            case 'text/plain':
                $parser = new \Managers\Email\Text();
                break;
            default:
                $parser = new \Managers\Email\Excel();
        }
        $parsed = array_unique($parser->getParsed($fullPath));
        return $parsed;
    }
}
